package com.taotao.rest.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.taotao.pojo.TbUser;
import com.taotao.rest.dao.JedisClient;
import com.taotao.utils.JsonUtils;
@Service
public class LogServiceImpl implements LogService {
	@Autowired
	private JedisClient jedisClient;
	@Value("${REDIS_USER_SESSION_KEY}")
	private String REDIS_USER_SESSION_KEY;
	
	@Value("${SSO_SESSION_EXPIRE}")
	private Integer SSO_SESSION_EXPIRE;
	@Override
	public TbUser isLogin(String token) {
		String string = jedisClient.get(REDIS_USER_SESSION_KEY+":"+token);
		if (string == null || string == "") {
			return null;
		}
		jedisClient.expire(REDIS_USER_SESSION_KEY + ":" + token, SSO_SESSION_EXPIRE);
		return JsonUtils.jsonToPojo(string, TbUser.class);
	}

}
